//
//  BlindDetalViewController.m
//  jingdongfang
//
//  Created by MTiMac02 on 2017/8/31.
//  Copyright © 2017年 LJL. All rights reserved.
//

#import "BlindDetalViewController.h"
#import "IGHandleMsgApi.h"
#import "IGAgreeOrNotBunding.h"

@interface BlindDetalViewController (){
    NSString *label;
}

@property (strong, nonatomic) IBOutlet UIImageView *iconimg;
@property (strong, nonatomic) IBOutlet UILabel *contentLabel;
@property (strong, nonatomic) IBOutlet UIButton *registBtn;
@property (strong, nonatomic) IBOutlet UIButton *acceptBtn;
@property (nonatomic, strong) IGHandleMsgApi *handleMsgApi;
@property (nonatomic, strong) IGAgreeOrNotBunding *agreeOrNotApi;
@end

@implementation BlindDetalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.title=@"绑定申请详情";
    self.title = NSLocalizedString(@"Details of Binding Application", nil);
    self.view.backgroundColor=[UIColor c2Color];
    self.handleMsgApi = [IGHandleMsgApi new];
    
    _iconimg=[[UIImageView alloc]init];
    _iconimg.image=[UIImage imageNamed:_blindModel.senderImg];
    _contentLabel.text=_blindModel.content;
    //拒绝
    [_registBtn.layer setCornerRadius:15.f];
    [_registBtn setBackgroundColor:[UIColor whiteColor]];
    [_registBtn.layer setBorderColor:[UIColor c4Color].CGColor];
    [_registBtn.layer setBorderWidth:1.0];
    [_registBtn addTarget:self action:@selector(rejectBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    //同意
    [_acceptBtn.layer setCornerRadius:15.f];
    [_acceptBtn setBackgroundColor:[UIColor whiteColor]];
    [_acceptBtn.layer setBorderColor:[UIColor c1Color].CGColor];
    [_acceptBtn.layer setBorderWidth:1.0];
    [_acceptBtn addTarget:self action:@selector(agreeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    self.agreeOrNotApi = [IGAgreeOrNotBunding new];
    
}
-(void)rejectBtnClick:(UIButton *)btn{
    self.agreeOrNotApi.apiType = IGBundingResultTypeDisAgree;
    self.agreeOrNotApi.macId = _blindModel.eId;
    self.agreeOrNotApi.btype = _blindModel.type;
    self.agreeOrNotApi.applyId = _blindModel.senderId;
    [self.agreeOrNotApi startWithDecodeClass:[IGAgreeOrNotBundingResp class] CompletionBlockWithSuccess:^(id responseObject, NSError *error) {
        if (responseObject) {
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
}

-(void)agreeBtnClick:(UIButton *)btn{
    self.agreeOrNotApi.apiType = IGBundingResultTypeAgree;
    self.agreeOrNotApi.macId = _blindModel.eId;
    self.agreeOrNotApi.btype = _blindModel.type;
    self.agreeOrNotApi.applyId = _blindModel.senderId;
    [self.agreeOrNotApi startWithDecodeClass:[IGAgreeOrNotBundingResp class] CompletionBlockWithSuccess:^(id responseObject, NSError *error) {
        if (responseObject) {
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
